#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import re
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QWidget
from DAC.SalleDAC import Salle
from DAC.BatimentDAC import Batiment


class Page3(QtGui.QMainWindow):

    def suivant(self):
       error=0
       self.recup_dico()
       self.parametre["id"]
       self.dico["nom"]=self.lineEdit_nom_vide.displayText()
       self.dico["realheight"]=self.lineEdit_longueur_vide.displayText()
       self.dico["realwidth"]=self.lineEdit_largeur_vide.displayText()
       self.dico["x"]=int(self.doubleSpinBox_x_number.value())
       self.dico["y"]=int(self.doubleSpinBox_y_number.value())
       self.dico["z"]=int(self.doubleSpinBox_z_number.value())
       self.dico["url_plan"]=self.filename

       if ((self.lineEdit_nom_vide.displayText()=="") or (self.lineEdit_nom_vide.displayText()=="Le nom de la salle ici...")):
          self.lineEdit_nom_vide.setText("Le nom de la salle ici...")
          error=error+1
       if ((self.lineEdit_longueur_vide.displayText()=="") or (self.lineEdit_longueur_vide.displayText()=="cm")):
          self.lineEdit_longueur_vide.setText("cm")
          error=error+1
       if ((self.lineEdit_largeur_vide.displayText()=="") or (self.lineEdit_largeur_vide.displayText()=="cm")):
          self.lineEdit_largeur_vide.setText("cm")
          error=error+1       
       if (self.filename ==""):
          error=error+1

       if (error==0):
          salle=Salle()
          index=self.comboBox_salle.currentIndex()
          if(index >= 2):
		salle=Salle(self.list[index-2]["ID"])
        	salle.createByDico(self.dico)
        	salle.updateIntoDb(self.parametre["id"])
          else:   
		
        	salle.createByDico(self.dico)
		salle.insertToDb(self.parametre["id"])
          fichier=open('dicosalle','a')
          fichier.write('\nnom:'+self.lineEdit_nom_vide.displayText())
          fichier.write('\nrealheight:'+self.lineEdit_longueur_vide.displayText())
          fichier.write('\nrealwidth:'+self.lineEdit_largeur_vide.displayText())
          fichier.write('\nurl_plan:'+self.filename)
	  fichier.write('\npreviousheight:'+str(self.objImg.height()))
          fichier.write('\npreviouswidth:'+str(self.objImg.width()))
          fichier.write('\nnextheight:'+str(self.objImgModif.height()))
          fichier.write('\nnextwidth:'+str(self.objImgModif.width()))
	  fichier.write('\nx:'+str(self.dico["x"]))
          fichier.write('\ny:'+str(self.dico["y"]))
          fichier.write('\nz:'+str(self.dico["z"]))
	  fichier.write('\nid:'+str(salle.id["value"]))
          fichier.close()
          self.window.close()
          os.system("./Main.py 4")
  
             
    def precedent(self):
        self.window.close()
        os.system("./launch_page2.py")

    def affich(self,param):
	self.setupUi(self.window)
	self.window.show()
        sys.exit(self.app.exec_())

    def recup_dico(self):
        fichier=open("dicobatiment",'r')
        expr=re.compile("[A-Za-z]")
        for line in fichier.readlines():
           if expr.findall(line):
               self.parametre[line.split(":")[0].split("\n")[0]]=line.split(":")[1].split("\n")[0]
        fichier.close()
        
    def displaySalle(self):
    
      index=self.comboBox_salle.currentIndex()
 
      if index >= 2:
           self.lineEdit_nom_vide.setText(self.list[index-2]["nom"])
           self.lineEdit_longueur_vide.setText(str(self.list[index-2]["realheight"]))
           self.lineEdit_largeur_vide.setText(str(self.list[index-2]["realwidth"]))
           self.filename= self.list[index-2]["url_plan"]
           
           self.objImg = QtGui.QImage(self.filename) 
           self.objImgModif = self.objImg.scaled(530,460,Qt.KeepAspectRatio,Qt.FastTransformation)
	   a = self.objImgModif.height()
	   b = self.objImgModif.width()
	   self.repere_coord.resize(b,a)
	   self.doubleSpinBox_x_number.setValue(self.list[index-2]["x"])
           self.doubleSpinBox_y_number.setValue(self.list[index-2]["y"])
           self.doubleSpinBox_z_number.setValue(self.list[index-2]["z"])
           
        # affichage de l'objet image dans le label
           self.plan.clear()
	   self.plan.setGeometry(QtCore.QRect(0,0,b,a))
	   self.plan.setPixmap(QtGui.QPixmap.fromImage(self.objImgModif))
	   self.repere.setVisible(True)
     #url + x,y,z
      else:
           self.lineEdit_nom_vide.setText("Le nom de la salle ici...")
           self.lineEdit_longueur_vide.setText("cm")
           self.lineEdit_largeur_vide.setText("cm")
           self.filename= "../images/vide.jpg"
           
           self.objImg = QtGui.QImage(self.filename) 
           self.objImgModif = self.objImg.scaled(530,460,Qt.KeepAspectRatio,Qt.FastTransformation)
	   a = self.objImgModif.height()
	   b = self.objImgModif.width()
	   self.repere_coord.resize(b,a)
	   self.doubleSpinBox_x_number.setValue(0)
           self.doubleSpinBox_y_number.setValue(0)
           self.doubleSpinBox_z_number.setValue(0)
           
        # affichage de l'objet image dans le label
           self.plan.clear()
	   self.plan.setGeometry(QtCore.QRect(0,0,b,a))
	   self.plan.setPixmap(QtGui.QPixmap.fromImage(self.objImgModif))
	   self.repere.setVisible(False)
      


    def setupUi(self, Dialog):

   
        os.system("echo>dicosalle")
        self.window=Dialog
        self.parametre={}
        self.filename = ""
        self.dico={}
        Dialog.setObjectName("Dialog")
        Dialog.resize(1280, 740)

        #Longueur
        self.textEdit_verticale_longueur = QtGui.QTextEdit(Dialog)
        self.textEdit_verticale_longueur.setGeometry(QtCore.QRect(658, 250, 23, 190))
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.textEdit_verticale_longueur.sizePolicy().hasHeightForWidth())
        self.textEdit_verticale_longueur.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.textEdit_verticale_longueur.setFont(font)
        self.textEdit_verticale_longueur.setFrameShape(QtGui.QFrame.VLine)
        self.textEdit_verticale_longueur.setReadOnly(True)
        self.textEdit_verticale_longueur.setObjectName("textEdit_verticale_longueur")
        self.lineEdit_site = QtGui.QLineEdit(Dialog)
        self.lineEdit_site.setGeometry(QtCore.QRect(440,14,370,71))

        #Largeur
        self.textEdit_horizontal_largeur = QtGui.QTextEdit(Dialog)
        self.textEdit_horizontal_largeur.setGeometry(QtCore.QRect(880, 107, 110, 27))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.textEdit_horizontal_largeur.setFont(font)
        self.textEdit_horizontal_largeur.setReadOnly(True)
        self.textEdit_horizontal_largeur.setObjectName("textEdit_horizontal_largeur")

        self.lineEdit_salles = QtGui.QLineEdit(Dialog)
        self.lineEdit_salles.setGeometry(QtCore.QRect(440, 20, 382, 65))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(32)
        font.setWeight(50)
        font.setBold(False)
        self.lineEdit_salles.setFont(font)
        self.lineEdit_salles.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_salles.setReadOnly(True)
        self.lineEdit_salles.setObjectName("lineEdit_salles")
        
        self.groupe_informations = QtGui.QWidget(Dialog)
        self.groupe_informations.setGeometry(QtCore.QRect(10,100,651,591))
        self.groupe_informations.setObjectName("groupe_informations")

	self.lineEdit_nom = QtGui.QLineEdit(Dialog)
        self.lineEdit_nom.setGeometry(QtCore.QRect(20, 270, 91, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_nom.setFont(font)
        self.lineEdit_nom.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_nom.setReadOnly(True)
        self.lineEdit_nom.setObjectName("lineEdit_nom")
        self.lineEdit_nom_vide = QtGui.QLineEdit(Dialog)
        self.lineEdit_nom_vide.setGeometry(QtCore.QRect(110, 270, 521, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_nom_vide.setFont(font)
        self.lineEdit_nom_vide.setObjectName("lineEdit_nom_vide")
        self.lineEdit_coordonnees_ref_rel = QtGui.QLineEdit(Dialog)
        self.lineEdit_coordonnees_ref_rel.setGeometry(QtCore.QRect(20, 400, 501, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_coordonnees_ref_rel.setFont(font)
        self.lineEdit_coordonnees_ref_rel.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_coordonnees_ref_rel.setReadOnly(True)
        self.lineEdit_coordonnees_ref_rel.setObjectName("lineEdit_coordonnees_ref_rel")
        self.lineEdit_longueur = QtGui.QLineEdit(Dialog)
        self.lineEdit_longueur.setGeometry(QtCore.QRect(20, 530, 301, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        font.setItalic(False)
        self.lineEdit_longueur.setFont(font)
        self.lineEdit_longueur.setAutoFillBackground(False)
        self.lineEdit_longueur.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_longueur.setReadOnly(True)
        self.lineEdit_longueur.setObjectName("lineEdit_longueur")


        self.pushButton_suivant = QtGui.QPushButton(Dialog)
        self.pushButton_suivant.setGeometry(QtCore.QRect(1080, 650, 171, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_suivant.setFont(font)
        self.pushButton_suivant.setObjectName("pushButton_suivant")
        self.pushButton_annuler = QtGui.QPushButton(Dialog)
        self.pushButton_annuler.setGeometry(QtCore.QRect(740, 650, 171, 41))
 
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_annuler.setFont(font)
        self.pushButton_annuler.setObjectName("pushButton_annuler")
        self.lineEdit_x = QtGui.QLineEdit(Dialog)
        self.lineEdit_x.setGeometry(QtCore.QRect(20, 470, 51, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_x.setFont(font)
        self.lineEdit_x.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_x.setReadOnly(True)
        self.lineEdit_x.setObjectName("lineEdit_x")
        self.lineEdit_y = QtGui.QLineEdit(Dialog)
        self.lineEdit_y.setGeometry(QtCore.QRect(250, 470, 51, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_y.setFont(font)
        self.lineEdit_y.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_y.setReadOnly(True)
        self.lineEdit_y.setObjectName("lineEdit_y")
        self.lineEdit_etage = QtGui.QLineEdit(Dialog)
        self.lineEdit_etage.setGeometry(QtCore.QRect(450, 470, 71, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_etage.setFont(font)
        self.lineEdit_etage.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_etage.setReadOnly(True)
        self.lineEdit_etage.setObjectName("lineEdit_etage")
        self.doubleSpinBox_x_number = QtGui.QDoubleSpinBox(Dialog)
        self.doubleSpinBox_x_number.setGeometry(QtCore.QRect(80, 470, 91, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
	self.doubleSpinBox_x_number.setDecimals(0)
        self.doubleSpinBox_x_number.setFont(font)
        self.doubleSpinBox_x_number.setAlignment(QtCore.Qt.AlignCenter)
        self.doubleSpinBox_x_number.setMinimum(-1000.0)
        self.doubleSpinBox_x_number.setMaximum(1000.0)
        self.doubleSpinBox_x_number.setObjectName("doubleSpinBox_x_number")
        self.doubleSpinBox_y_number = QtGui.QDoubleSpinBox(Dialog)
        self.doubleSpinBox_y_number.setGeometry(QtCore.QRect(310, 470, 91, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.doubleSpinBox_y_number.setFont(font)
	self.doubleSpinBox_y_number.setDecimals(0)
        self.doubleSpinBox_y_number.setAlignment(QtCore.Qt.AlignCenter)
        self.doubleSpinBox_y_number.setMinimum(-1000.0)
        self.doubleSpinBox_y_number.setMaximum(1000.0)
        self.doubleSpinBox_y_number.setProperty("value", QtCore.QVariant(0.0))
        self.doubleSpinBox_y_number.setObjectName("doubleSpinBox_y_number")
        self.pushButton_precedent = QtGui.QPushButton(Dialog)
        self.pushButton_precedent.setGeometry(QtCore.QRect(910, 650, 171, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_precedent.setFont(font)
        self.pushButton_precedent.setObjectName("pushButton_precedent")
        self.lineEdit_Salles_existantes = QtGui.QLineEdit(Dialog)
        self.lineEdit_Salles_existantes.setGeometry(QtCore.QRect(20, 100, 241, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_Salles_existantes.setFont(font)
        self.lineEdit_Salles_existantes.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_Salles_existantes.setReadOnly(True)
        self.lineEdit_Salles_existantes.setObjectName("lineEdit_Salles_existantes")
        self.lineEdit_nouvelle_salle = QtGui.QLineEdit(Dialog)
        self.lineEdit_nouvelle_salle.setGeometry(QtCore.QRect(20, 220, 201, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_nouvelle_salle.setFont(font)
        self.lineEdit_nouvelle_salle.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_nouvelle_salle.setReadOnly(True)
        self.lineEdit_nouvelle_salle.setObjectName("lineEdit_nouvelle_salle")
        self.pushButton_nouvelle_salle = QtGui.QPushButton(Dialog)
        self.pushButton_nouvelle_salle.setGeometry(QtCore.QRect(570, 650, 171, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(12)
        self.pushButton_nouvelle_salle.setFont(font)
        self.pushButton_nouvelle_salle.setObjectName("pushButton_nouvelle_salle")
        self.doubleSpinBox_z_number = QtGui.QDoubleSpinBox(Dialog)
        self.doubleSpinBox_z_number.setGeometry(QtCore.QRect(530, 470, 91, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.doubleSpinBox_z_number.setFont(font)
	self.doubleSpinBox_z_number.setDecimals(0)
        self.doubleSpinBox_z_number.setAlignment(QtCore.Qt.AlignCenter)
        self.doubleSpinBox_z_number.setMinimum(-1000.0)
        self.doubleSpinBox_z_number.setMaximum(1000.0)
        self.doubleSpinBox_z_number.setObjectName("doubleSpinBox_z_number")
        self.lineEdit_longueur_vide = QtGui.QLineEdit(Dialog)
        self.lineEdit_longueur_vide.setGeometry(QtCore.QRect(320, 530, 121, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_longueur_vide.setFont(font)
        self.lineEdit_longueur_vide.setObjectName("lineEdit_longueur_vide")
        self.lineEdit_longueur_vide.setText("cm")
        self.lineEdit_largeur = QtGui.QLineEdit(Dialog)
        self.lineEdit_largeur.setGeometry(QtCore.QRect(20, 570, 301, 41))

        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.lineEdit_largeur.setFont(font)
        self.lineEdit_largeur.setAlignment(QtCore.Qt.AlignCenter)
        self.lineEdit_largeur.setReadOnly(True)
        self.lineEdit_largeur.setObjectName("lineEdit_largeur")
        self.lineEdit_largeur_vide = QtGui.QLineEdit(Dialog)
        self.lineEdit_largeur_vide.setGeometry(QtCore.QRect(320, 570, 121, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)

        self.lineEdit_largeur_vide.setFont(font)
        self.lineEdit_largeur_vide.setObjectName("lineEdit_largeur_vide")
        self.lineEdit_largeur_vide.setText("cm")
        self.pushButton_inserer_plan = QtGui.QPushButton(Dialog)
        self.pushButton_inserer_plan.setGeometry(QtCore.QRect(290, 220, 341, 41))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        font.setPointSize(14)
        self.pushButton_inserer_plan.setFont(font)
        self.pushButton_inserer_plan.setObjectName("pushButton_inserer_plan")
        self.comboBox_salle = QtGui.QComboBox(Dialog)
        self.comboBox_salle.setGeometry(QtCore.QRect(20, 160, 611, 31))
        font = QtGui.QFont()
        font.setFamily("Bitstream Charter")
        self.comboBox_salle.setFont(font)
        self.comboBox_salle.setObjectName("comboBox_AP_existants")
        self.comboBox_salle.addItem("...")
        self.comboBox_salle.addItem("nouvelle salle")
        self.recup_dico()
        batiment=Batiment(self.parametre["id"])
        
        self.list=batiment.selectSallesFromDB()
        for salle in self.list:
             self.comboBox_salle.addItem(salle["nom"])
        
        self.groupe_image = QtGui.QWidget(Dialog)
        self.groupe_image.setGeometry(QtCore.QRect(670,130,571,511))
        self.groupe_image.setObjectName("groupe_image")

        #cadre autour du plan
        self.frame = QtGui.QFrame(self.groupe_image)
        self.frame.setGeometry(QtCore.QRect(10,10,551,481))
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.frame.setObjectName("frame")       


	self.repere_coord = QtGui.QWidget(self.frame)
	self.repere_coord.setObjectName("repere_coord")
        self.repere_coord.setGeometry(QtCore.QRect(10,10,551,481))

        # label qui contiendra le plan
        self.plan = QtGui.QLabel(self.repere_coord)

        # objet-image
        self.objImg = QtGui.QImage("../images/vide.jpg")
	self.objImgRepere = QtGui.QImage("../images/pointeur1.png")

	# label qui contiendra le repère
	self.repere = QtGui.QLabel(self.repere_coord)
        self.repere.setGeometry(QtCore.QRect(0,0,self.objImgRepere.height(),self.objImgRepere.width()))
	self.repere.setVisible(False)

        # Initialisation du label
	self.plan.setPixmap(QtGui.QPixmap.fromImage(self.objImg.scaled(530,460,Qt.KeepAspectRatio,Qt.FastTransformation)))
	self.repere.setPixmap(QtGui.QPixmap.fromImage(self.objImgRepere))

        self.textEdit_verticale_longueur.setHtml(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Bitstream Charter\'; font-size:12pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">L</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">O</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">N</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">G</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">U</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">E</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">U</p>\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">R</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))

        self.textEdit_horizontal_largeur.setHtml(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Bitstream Charter\'; font-size:12pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'DejaVu Sans\'; font-size:9pt;\"><span style=\" font-family:\'Sans Serif\'; font-size:10pt;\">L A R G E U R</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
 


        self.retranslateUi(Dialog)
        QtCore.QObject.connect(self.pushButton_annuler, QtCore.SIGNAL("clicked()"), Dialog.accept)
        QtCore.QObject.connect(self.pushButton_nouvelle_salle, QtCore.SIGNAL("clicked()"), Dialog.accept)
        QtCore.QObject.connect(self.pushButton_precedent, QtCore.SIGNAL("clicked()"),self.precedent)
        QtCore.QObject.connect(self.pushButton_suivant, QtCore.SIGNAL("clicked()"),self.suivant)
        QtCore.QObject.connect(self.pushButton_inserer_plan, QtCore.SIGNAL("clicked()"), self.parcourir)
        QtCore.QObject.connect(self.comboBox_salle, QtCore.SIGNAL("activated(QString)"), self.displaySalle) 
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_salles.setText(QtGui.QApplication.translate("Dialog", "SALLES", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_nom.setText(QtGui.QApplication.translate("Dialog", "Nom :", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_coordonnees_ref_rel.setText(QtGui.QApplication.translate("Dialog", "Coordonnées de la référence relative :", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_longueur.setText(QtGui.QApplication.translate("Dialog", "Longueur de la salle :", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_suivant.setText(QtGui.QApplication.translate("Dialog", "Suivant >>", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_annuler.setText(QtGui.QApplication.translate("Dialog", "Annuler", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_x.setText(QtGui.QApplication.translate("Dialog", "X :", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_y.setText(QtGui.QApplication.translate("Dialog", "Y :", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_etage.setText(QtGui.QApplication.translate("Dialog", "Z :", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_precedent.setText(QtGui.QApplication.translate("Dialog", "<< Précédent", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_Salles_existantes.setText(QtGui.QApplication.translate("Dialog", "Salles existantes", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_nouvelle_salle.setText(QtGui.QApplication.translate("Dialog", "Nouvelle salle", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_nouvelle_salle.setText(QtGui.QApplication.translate("Dialog", "Nouvelle salle", None, QtGui.QApplication.UnicodeUTF8))
        self.lineEdit_largeur.setText(QtGui.QApplication.translate("Dialog", "Largeur de la salle :", None, QtGui.QApplication.UnicodeUTF8))
        self.pushButton_inserer_plan.setText(QtGui.QApplication.translate("Dialog", "Insérer le plan de la salle", None, QtGui.QApplication.UnicodeUTF8))

    def parcourir(self):
        
	# On récupère le chemin de l'image à récupérer
	self.filename = str(QtGui.QFileDialog.getOpenFileName(self, 'Open file', '/home'))

	# test pour vérifier que le chemin à bien été récupéré	
	b="echo "+self.filename	
	os.system(b)

        # création d'un objet image pour pouvoir la manipuler ensuite
        self.objImg = QtGui.QImage(self.filename)

	# redimensionnement de l'image
	self.objImgModif = self.objImg.scaled(530,460,Qt.KeepAspectRatio,Qt.FastTransformation)

	# taille de l'image
	a = self.objImgModif.height()
	b = self.objImgModif.width()
	
        
        
        # redimensionnement du widget
	self.repere_coord.resize(b,a)

        # affichage de l'objet image dans le label
        self.plan.clear()
	self.plan.setGeometry(QtCore.QRect(0,0,b,a))
	self.plan.setPixmap(QtGui.QPixmap.fromImage(self.objImgModif))
	
	self.repere.setVisible(True)

